1 <?php
2     include(
"../includes/config.php");
3     session_start();
4     
if(isset($_SESSION['manufacturer_login'])) {
5         
if($_SESSION['manufacturer_login'] == true) {
6             $query_selectCategory =
"SELECT * FROM categories";
7             $result_selectCategory = mysqli_query($con,$query_selectCategory);
8             
if($_SERVER['REQUEST_METHOD'] == "POST") {
9                 
if(isset($_POST['chkId'])) {
10                     $chkId = $_POST[
'chkId'];
11                     
foreach($chkId as $id) {
12                         $query_deleteCategory =
"DELETE FROM categories WHERE cat_id='$id'";
13                         $result = mysqli_query($con,$query_deleteCategory);
14                     }
15                     
if(!$result) {
16                         echo
"<script> alert(\"Categories assigned to any product can not be deleted\"); </script>";
17                         header(
'Refresh:0');
18                     }
19                     
else {
20                         echo
"<script> alert(\"Category Deleted Successfully\"); </script>";
21                         header(
'Refresh:0');
22                     }
23                 }
24             }
25         }
26         
else {
27             header(
'Location:../index.php');
28         }
29     }
30     
else {
31         header(
'Location:../index.php');
32     }
33 ?>
34 <!DOCTYPE html>
35 <html>
36 <head>
37     <title> View Category </title>
38     <link rel=
"stylesheet" href="../includes/main_style.css" >
39     <script language=
"JavaScript">
40     function toggle(source) {
41         checkboxes = document.getElementsByName(
'chkId[]');
42         
for(var i=0, n=checkboxes.length;i<n;i++) {
43             checkboxes[i].
checked = source.checked;
44         }
45     }
46     </script>
47 </head>
48 <body>
49     <?php
50         include(
"../includes/header.inc.php");
51         include(
"../includes/nav_manufacturer.inc.php");
52         include(
"../includes/aside_manufacturer.inc.php");
53     ?>
54     <section>
55         <h1>View Category</h1>
56         <form action=
"" method="POST" class="form">
57         <table
class="table_displayData">
58             <tr>
59                 <th> <input type=
"checkbox" onClick="toggle(this)" /> </th>
60                 <th>Sr. No.</th>
61                 <th>Name</th>
62                 <th>Description</th>
63                 <th> Edit </th>
64             </tr>
65             <?php $i=
1; while($row_selectCategory = mysqli_fetch_array($result_selectCategory)) { ?>
66             <tr>
67                 <td> <input type=
"checkbox" name="chkId[]" value="<?php echo $row_selectCategory['cat_id']; ?>" /> </td>
68                 <td> <?php echo $i; ?> </td>
69                 <td> <?php echo $row_selectCategory[
'cat_name']; ?> </td>
70                 <td> <?php echo $row_selectCategory[
'cat_details']; ?> </td>
71                 <td> <a href=
"edit_category.php?id=<?php echo $row_selectCategory['cat_id']; ?>"><img src="../images/edit.png" alt="edit" /></a> </td>
72             </tr>
73             <?php $i++; } ?>
74         </table>
75         <input type=
"submit" value="Delete" class="submit_button"/>
76         <a href=
"add_category.php"><input type="button" value="+ Add Category" class="submit_button"/></a>
77         </form>
78     </section>
79     <?php
80         include(
"../includes/footer.inc.php");
81     ?>
82 </body>
83 </html>


Gõ tìm kiếm nhanh...